﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_DesignListFileController : BaseApiController
    {
        #region DI

        public PB_DesignListFileController(IPB_DesignListFileBusiness pB_DesignListFileBus)
        {
            _pB_DesignListFileBus = pB_DesignListFileBus;
        }

        IPB_DesignListFileBusiness _pB_DesignListFileBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_DesignListFile>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_DesignListFileBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_DesignListFile> GetTheData(IdInputDTO input)
        {
            return await _pB_DesignListFileBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_DesignListFile data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_DesignListFileBus.AddDataAsync(data);
            }
            else
            {
                await _pB_DesignListFileBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_DesignListFileBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 保存设计清单文件上传接口
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddDesignListFile(PB_DesignListDetailsDing data) {
            await _pB_DesignListFileBus.AddDesignListFile(data);
        }
        #endregion
    }
}